﻿/*
 * Class description: manage article comment method
 * @Reviewed by: Anhtu79
 * @Reviewed date: 04/06/12
 * */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HelloMinasan.Data;
using HelloMinasan.Data.Extend;
using HelloMinasan.Domain;
using HelloMinasan.Domain.Dtos;
using HelloMinasan.UserDefinedType.Dtos;

namespace HelloMinasan.Business.Extend
{
    public class SongService : Service<Song>, ISongService
    {
        private ISongRepository songRepository;

        public SongService(ISongRepository songRepository)
            : base(songRepository)
        {
            this.songRepository = songRepository;
        }

        //public IList<ArticleCommentDto> GetArticleCommentList(int articleId, int languageId)
        //{
        //    return songRepository.GetArticleCommentList(articleId, languageId);
        //}
        public TypeSong GetTypeSong(int id)
        {
            return songRepository.GetTypeSong(id);
        }

        public IEnumerable<Song> GetSongsByUsername(int userId, int page = 1)
        {
            return songRepository.GetSongsByUsername(userId, page);
        }

        public IEnumerable<Song> GetAllSongs(int page = 1)
        {
            return songRepository.GetAllSongs(page);
        }

        public Song GetSongContent(int songId, bool isUpView = false)
        {
            return songRepository.GetSongContent(songId, isUpView);
        }

        public int AddSong(Song songObject)
        {
            return songRepository.AddSong(songObject);
        }

        public void DeleteSong(int songId)
        {
            songRepository.DeleteSong(songId);
        }

        public void LockSong(int songId, bool isLocked = true)
        {
            songRepository.LockSong(songId, isLocked);
        }

        public IEnumerable<Song> GetRelativeSong(Song songObj)
        {
            return songRepository.GetRelativeSong(songObj);
        }


        public IEnumerable<Song> GetSongsByUsername(int userId)
        {
            return songRepository.GetSongsByUsername(userId);
        }

        public void EditSong(Song songObject)
        {
            songRepository.EditSong(songObject);
        }


        public void EditGrammar(Song songObject)
        {
            songRepository.EditGrammar(songObject);
        }

        public void EditSongFiles(Song songObject)
        {
            songRepository.EditSongFiles(songObject);
        }

        public void AddLyric(LyricDetail lyricObject)
        {
            songRepository.AddLyric(lyricObject);
        }

        public void EditLyric(IEnumerable<LyricDetail> lyricObjects)
        {
            songRepository.EditLyric(lyricObjects);
        }


        public IEnumerable<LyricDetail> GetLyricBySongId(int songId)
        {
            return songRepository.GetLyricBySongId(songId);
        }


        public void UpdateScore(int userId, int score)
        {
            songRepository.UpdateScore(userId, score);
        }


        public void CommunityUpdateLyric(LyricDetail lyricDetail, int userId)
        {
            songRepository.CommunityUpdateLyric(lyricDetail, userId);
        }

        public void CommunityUpdateEmbedLink(Song songObject, int userId)
        {
            songRepository.CommunityUpdateEmbedLink(songObject, userId);
        }

        public IEnumerable<Language> GetLanguage(bool isSelectAll, int songId = 0)
        {
            return songRepository.GetLanguage(isSelectAll, songId);
        }


        public void CommunityAddMoreLyric(LyricDetail lyric)
        {
            songRepository.CommunityAddMoreLyric(lyric);
        }


        public void AddTestQuiz(QuestionQuiz model)
        {
            songRepository.AddTestQuiz(model);
        }


        public void CommunityGrammar(Song song)
        {
            songRepository.CommunityGrammar(song);
        }


        public void AddTestBlank(QuestionBlank model)
        {
            songRepository.AddTestBlank(model);
        }


        public void LikeSong(int userId, int songId)
        {
            songRepository.LikeSong(userId, songId);
        }


        public IEnumerable<Song> SearchSong(string keyword, int pageNumber, bool isOnlyUnapprove, int userId = 0)
        {
            return songRepository.SearchSong(keyword, pageNumber, isOnlyUnapprove, userId);
        }


        public int SearchSongCount(string keyword, int pageNumber, bool isOnlyUnapprove, int userId = 0)
        {
            return songRepository.SearchSongCount(keyword, pageNumber, isOnlyUnapprove, userId);
        }


        public void UpdateTestBlank(QuestionBlank model)
        {
            songRepository.UpdateTestBlank(model);
        }


        public void UpdateTestQuiz(QuestionQuiz model)
        {
            songRepository.UpdateTestQuiz(model);
        }


        public void DeleteTest(int testId, bool type)
        {
            songRepository.DeleteTest(testId, type);
        }


        public void ApproveLyric(int lyricId, bool typeAction)
        {
            songRepository.ApproveLyric(lyricId, typeAction);
        }

        //Home repository moved
        public IEnumerable<Song> GetTopHighestSongs()
        {
            return songRepository.GetTopHighestSongs();
        }

        public IEnumerable<QA> GetTopNewestQAs()
        {
            return songRepository.GetTopNewestQAs();
        }

        public IEnumerable<User> GetTopHighestUsers()
        {
            return songRepository.GetTopHighestUsers();
        }

        public int TotalSongCount()
        {
            return songRepository.TotalSongCount();
        }

        public int TotalUserCount()
        {
            return songRepository.TotalUserCount();
        }

        public int TotalThreadCount()
        {
            return songRepository.TotalThreadCount();
        }


        public IEnumerable<Song> GetSearchSongs(string keyword)
        {
            return songRepository.GetSearchSongs(keyword);
        }

        //Favoriated song
        public void AddFavouriteSong(int songId, int userId)
        {
            songRepository.AddFavouriteSong(songId, userId);
        }

        public void DeleteFavouriteSong(int songId, int userId)
        {
            songRepository.DeleteFavouriteSong(songId, userId);
        }

        public IEnumerable<FavouriteSong> GetMyFavouriteSongs(int userId, string keyword, out int totalItem, int page = 1)
        {
            return songRepository.GetMyFavouriteSongs(userId, keyword, out totalItem, page);
        }

        //Friend
        public IEnumerable<Relationship> GetFriendsByUsername(int userId, int page = 1)
        {
            return songRepository.GetFriendsByUsername(userId, page);
        }


        public void AddFriend(int userId1, int userId2)
        {
            songRepository.AddFriend(userId1, userId2);
        }


        public void DeleteFriends(int userId1, int userId2)
        {
            songRepository.DeleteFriends(userId1, userId2);
        }

        //relationshipt
        public IEnumerable<Relationship> GetFriends(int userId, out int totalItems, string keyword, int pageNumber = 1)
        {
            return songRepository.GetFriends(userId, out totalItems, keyword, pageNumber);
        }

        public void DeleteFriend(int userId1, int userId2)
        {
            songRepository.DeleteFriend(userId1, userId2);
        }

        //SongBankTestRepository
        public LyricDetail Get_SongLyric(int SongID)
        {
            return songRepository.Get_SongLyric(SongID);
        }

        public void Save_SongLyric(QuestionBlank question)
        {
            songRepository.Save_SongLyric(question);
        }

        public Song Get_SongSong(int songid)
        {
            return songRepository.Get_SongSong(songid);
        }

        public QuestionBlank Get_QuestionBank(int songid)
        {
            return songRepository.Get_QuestionBank(songid);
        }

        //Song comment
        public IEnumerable<SongComment> GetSongSommentsBySongId(int songId, out int totalPageCount, int page = 1)
        {
            return songRepository.GetSongSommentsBySongId(songId, out totalPageCount, page);
        }

        public IEnumerable<SongComment> GetAllSongComments(int page = 1)
        {
            return new List<SongComment>();
        }

        public SongComment GetCommentContent(int commentId)
        {
            return songRepository.GetCommentContent(commentId);
        }

        public int AddComment(SongComment songObject)
        {
            return songRepository.AddComment(songObject);
        }

        public void DeleteComment(int commentId)
        {
            throw new NotImplementedException();
        }

        public void UpdateComment(int commentId, string commentContent)
        {
            songRepository.UpdateComment(commentId, commentContent);
        }

        //song report
        public void AddReport(SongReport report)
        {
            songRepository.AddReport(report);
        }

        public IEnumerable<SongReport> GetAllReport(int page = 1, int number = 10, string ReportType = "1")
        {
            return songRepository.GetAllReport(page, number, ReportType);
        }

        public SongReport GetReport(int reportId)
        {
            throw new NotImplementedException();
        }

        public void DeleteReport(int reportId)
        {
            songRepository.DeleteReport(reportId);
        }

        public IEnumerable<SongReport> GetSongReport(int songid, int page = 1, int number = 10)
        {
            return songRepository.GetSongReport(songid, page, number);
        }

        public IEnumerable<SongReport> GetLyricReport(int songid, int Lyric, int page = 1, int number = 10)
        {
            return songRepository.GetLyricReport(songid, Lyric, page, number);
        }

        public IEnumerable<SongReport> GetCommentReport(int songid, int commentid, int page = 1, int number = 10)
        {
            return songRepository.GetCommentReport(songid, commentid, page, number);
        }

        public void UpdateStatus(SongReport songreport)
        {
            songRepository.UpdateStatus(songreport);
        }

        public IEnumerable<BadWordsFilter> GetBadWord()
        {
            return songRepository.GetBadWord();
        }

        public void AddBadWork(BadWordsFilter BadWords)
        {
            songRepository.AddBadWork(BadWords);
        }

        public bool CheckExistBadWord(string BadWord, int lang)
        {
            return songRepository.CheckExistBadWord(BadWord, lang);
        }

        public int SumReport(string type, int id)
        {
            return songRepository.SumReport(type, id);
        }

        public int SumReportType(string type)
        {
            return songRepository.SumReportType(type);
        }

        public IEnumerable<UserNote> GetNotes(int userId, out int total, int currentPage)
        {
            return songRepository.GetNotes(userId, out total, currentPage);
        }

        //QA
        //lấy danh sách QA xem nhiều nhất
        public IList<QA> QA_TopView()
        {
            return songRepository.QA_TopView();
        }
        //lấy danh sách QA theo loại
        public IList<QA> QA_Catagory(string para)
        {
            return songRepository.QA_Catagory(para);
        }
        //Lấy danh sách QA mới nhất 10 dòng
        public IList<QA> QA_TopNew()
        {
            return songRepository.QA_TopNew();
        }
        //Lấy danh sách QA được comment nhiều nhất(trả lời) 10 dòng
        public IList<QA> QA_TopAnsert()
        {
            return songRepository.QA_TopAnsert();
        }
        //lấy danh sách QA xem nhiều nhất chỉ lấy 5 dòng
        public IList<QA> QA_TopNew5()
        {
            return songRepository.QA_TopNew5();
        }
        //tìm QA với mã truyền vào
        public QA FindQaByID(int QaId)
        {
            return songRepository.FindQaByID(QaId);
        }
        //tạo mới 1 QA
        public void CreateQA(QA Qa)
        {
            songRepository.CreateQA(Qa);
        }
        //
        public void UpdateView(QA Qa)
        {
            songRepository.UpdateView(Qa);
        }
        //tạo mới 1 QA comment
        public void CreateComany(QAComment Qacom)
        {
            songRepository.CreateComany(Qacom);
        }
        //thanks
        public void UpdateThanks(QA Qa)
        {
            songRepository.UpdateThanks(Qa);
        }
        //tim user name
        public string SreachUserName(int ID)
        {
            return songRepository.SreachUserName(ID);
        }
    }
}
